#!/usr/bin/python
# -*- coding: utf-8 -*-
#coding=utf-8

import random
import datetimeDemo as tsLog
def demo():
    tsLog.logTs("randomDemo", preNewLineNum=2)

    print("0-1之间的浮点数            ", random.random())

    print("0-1之间的浮点数，2位精度    ", round(random.random(), 2))

    print("[1,100]之间的浮点数，2位精度", round(random.uniform(1, 100), 2))

    print("[1,100]之间的整数         ", random.randint(1, 100))

    print("从序列中随机取一个元素      ", random.choice(['剪刀', '石头', '布']))

    rnd = ''.join(random.sample('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 32))
    print("生成字母数字组成的32位密钥   ", rnd)

    # 扑克洗牌
    poker = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
    print("扑克牌", poker)
    random.shuffle(poker)
    print("扑克洗牌后", poker)

if __name__ == '__main__':
    demo()
    demo()